package com.xcity.game.relation;

import java.text.MessageFormat;

import com.xcity.db.entity.Player;
import com.xcity.game.common.AbstractConfirmOperation;
import com.xcity.game.common.GameStaticConfig;
import com.xcity.game.common.MessageConst;
import com.xcity.game.player.PlayerUtils;
import com.xcity.game.player.cache.PlayerCacheService;
import com.xcity.pomelo.push.msg.TipPush;

import naga.x.App;

public class AskPresentStrengthOperation extends AbstractConfirmOperation {

	private long target;
	
	public AskPresentStrengthOperation(Player player, Player target) {
		super(player,MessageFormat.format(
				MessageConst.ASK_PRESENT_STRENGTH_HINT,
				target.getId(),
				GameStaticConfig.presentStr));
		this.target = target.getId();
	}

	@Override
	public void ok(Player player) {
		Player targetPlayer = App.getApp().getServiceManager().get(PlayerCacheService.class).find(target);
		String error = PlayerUtils.presentStrength(player, targetPlayer);
		if (error != null) {
			player.send(new TipPush(error));
		}
	}

}
